home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / cshel40a / part01 next >
Encoding:
Internet Message Format  |  1990-01-15  |  56.1 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i014: CShell 4.00A - alternative command interface, Part01/04
  5. Message-ID: <10987@xanth.cs.odu.edu>
  6. Date: 15 Jan 90 16:28:25 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: PERUGIA@ICNUCEVM.CNUCE.CNR.IT (Carlo & Cesare)
  9. Lines: 2260
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11.  
  12. Submitted-by: PERUGIA@ICNUCEVM.CNUCE.CNR.IT (Carlo & Cesare)
  13. Posting-number: Volume 90, Issue 014
  14. Archive-name: unix/cshell-4.00a/part01
  15.  
  16. Shell provides a convient AmigaDos alternative command interface.  All
  17. its commands are internal and thus does not rely on the c: commands
  18. for any functionality.
  19.  
  20. New to 4.00A:
  21.  
  22. - This version is called 4.00A because it is not 100% compatible with
  23.   previous versions. We choose to accept this in order to better support
  24.   the new ARP.library 1.3.
  25. - External commands are searched in a different order than before; Shell
  26.   path is now searched AFTER current directory, AmigaDOS path and C:.
  27. - ARP pattern matching has been implemented (in part for line arg expanding,
  28.   fully for search -w).
  29. - Internal changes for various optimizations.
  30. - Search command has been improved in several ways.
  31. - New commands: basename, tackon.
  32. - New options: if -v, resident -d, fornum -v -s, dir -n.
  33. - Fixed bugs with dir (some dirs remained locked), foreach -v, htype
  34.   (blanks were treated as binary), info (for devices > 32M).
  35. - rback command now works ok (run, however, doesn't).
  36. - Oh, I forgot: it also has an AREXX port... And you don't even have to get
  37.   AREXX to use it. See new commands rxsend, rxrec
  38.  
  39. #! /bin/sh
  40. # This is a shell archive.  Remove anything before this line, then unpack
  41. # it by saving it into a file and typing "sh file".  To overwrite existing
  42. # files, type "sh file -c".  You can also feed this as standard input via
  43. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  44. # will see the following message at the end:
  45. #        "End of archive 1 (of 4)."
  46. # Contents:  comm3.c globals.c main.c makefile rawconsole.c run.c set.c
  47. #   shell.h shellfunctions.h
  48. # Wrapped by tadguy@xanth on Mon Jan 15 11:28:07 1990
  49. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  50. if test -f 'comm3.c' -a "${1}" != "-c" ; then 
  51.   echo shar: Will not clobber existing file \"'comm3.c'\"
  52. else
  53. echo shar: Extracting \"'comm3.c'\" \(12209 characters\)
  54. sed "s/^X//" >'comm3.c' <<'END_OF_FILE'
  55. X/*
  56. X * COMM3.C
  57. X *
  58. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  59. X *
  60. X */
  61. X
  62. Xdo_assign() {
  63. Xswitch(ac) {
  64. X    case 1:  assignlist();
  65. X         break;
  66. X    case 2:  doassign(av[1], NULL);
  67. X         break;
  68. X    case 3:  doassign(av[1], av[2]);
  69. X         break;
  70. X    default: ierror(NULL, 500);
  71. X         break;
  72. X    }
  73. Xreturn 0;
  74. X}
  75. X
  76. Xchar *assign_errors[4]={
  77. X    "",
  78. X    "Name %s is not valid\n",
  79. X    "Weird error\n",
  80. X    "Can't cancel %s\n"
  81. X    };
  82. X
  83. Xdoassign(log, phy)
  84. Xchar *log, *phy;
  85. X{
  86. Xint last=strlen(log) - 1;
  87. X
  88. Xif (log[last] != ':') fprintf(stderr, "Bad name %s\n", log);
  89. Xelse {
  90. X    log[last] = 0;
  91. X    fprintf(stderr,assign_errors[Assign(log, phy)],phy);
  92. X    }
  93. X}
  94. X
  95. Xassignlist()
  96. X{
  97. Xstruct DirectoryEntry *de_head=NULL, *de;
  98. Xchar buf[256];
  99. XBPTR lock;
  100. Xint ctr=0;
  101. X
  102. XAddDADevs(&de_head, DLF_DEVICES | DLF_VOLUMES | DLF_DIRS);
  103. Xprintf("Devices:\n");
  104. Xfor (de=de_head; de && de->de_Type==DLX_DEVICE; de=de->de_Next) {
  105. X    printf("%-8s",de->de_Name);
  106. X    if (ctr++ == 5) { ctr=0; printf("\n"); }
  107. X    }
  108. Xprintf("\n\nVolumes:\n");
  109. Xfor (    ;
  110. X    de && (de->de_Type==DLX_VOLUME || de->de_Type==DLX_UNMOUNTED);
  111. X    de=de->de_Next
  112. X    )
  113. X    printf( "%-16s %s\n",
  114. X        de->de_Name,
  115. X        de->de_Type == DLX_VOLUME ? "[Mounted]" : ""
  116. X        );
  117. Xprintf("\nDirectories:\n");
  118. Xfor (; de && de->de_Type==DLX_ASSIGN; de=de->de_Next) {
  119. X    if (lock=Lock(de->de_Name, ACCESS_READ)) {
  120. X        PathName(lock, buf, 256L);
  121. X        UnLock(lock);
  122. X        }
  123. X    else
  124. X        strcpy(buf,"Unexisting lock");
  125. X    printf("%-20s%s\n",de->de_Name,buf);
  126. X    }
  127. XFreeDAList(&de_head);
  128. X}
  129. X
  130. Xdo_join()
  131. X{
  132. XBPTR sou, dest;
  133. Xchar *buffer;
  134. Xunsigned int i;
  135. Xlong n;
  136. Xchar *namedest=av[--ac];
  137. X
  138. Xget_opt("r", &i);
  139. Xif (options==0 && exists(namedest)) { ierror(namedest,203); return 20; }
  140. Xif ( (buffer=malloc(8192)) == NULL ) { ierror(NULL,103); return 20; }
  141. Xif ( (dest=Open(namedest, MODE_NEWFILE)) == NULL )
  142. X    { pError(namedest); goto fail1; }
  143. Xfor (i=1; i<ac; i++) {
  144. X    if ( (sou=Open(av[i], MODE_OLDFILE)) == NULL ) pError(av[i]);
  145. X    else
  146. X        while( (n=Read(sou, buffer, 8192L)) > 0 )
  147. X            if (Write(dest, buffer, n) != n)
  148. X                { pError(namedest); Close(sou); goto fail2; }
  149. X    Close(sou);
  150. X    }
  151. Xfail2:
  152. X    Close(dest);
  153. Xfail1:
  154. X    free(buffer);
  155. X    return 0;
  156. X}
  157. X
  158. X#define BUFDIM 512L
  159. X#define MAXSTR 256
  160. X
  161. Xint minstr;
  162. X
  163. Xstrings_in_file(s)
  164. Xchar *s;
  165. X{
  166. Xchar c;
  167. Xchar readbuf[BUFDIM+1], strbuf[MAXSTR+1];
  168. Xregister unsigned int i, strctr=0;
  169. XBPTR fh;
  170. Xint out, n;
  171. X
  172. Xif ( fh=Open(s, MODE_OLDFILE) ) {
  173. X    fprintf(stderr, "Strings in %s (len>=%d):\n",s,minstr);
  174. X    while ( (n=(int)Read(fh, readbuf, BUFDIM)) > 0 && !CHECKBREAK() )
  175. X        for (i=0; i<n; i++) {
  176. X        c=readbuf[i];
  177. X        if (c<0x20 || c>0x7f) {
  178. X            out=(strctr>=minstr);
  179. X            if (!out) strctr=0;
  180. X            }
  181. X        else {
  182. X            strbuf[strctr++]=c;
  183. X            out=(strctr>=BUFDIM);
  184. X            }
  185. X        if (out) {
  186. X            strbuf[strctr]='\0';
  187. X            puts(strbuf);
  188. X            strctr=0;
  189. X            }
  190. X        }
  191. X    Close(fh);
  192. X    }
  193. Xelse pError(s);
  194. X}
  195. X
  196. Xdo_strings()
  197. X{
  198. Xminstr=myatoi(av[--ac],1,255);
  199. Xall_args("r", strings_in_file, 0);
  200. Xreturn 0;
  201. X}
  202. X
  203. XBPTR myfile[MAXMYFILES];
  204. X
  205. Xdo_open()
  206. X{
  207. Xlong mode;
  208. Xunsigned int n;
  209. X
  210. Xswitch (toupper(av[2][0])) {
  211. X    case 'R': mode=MODE_OLDFILE; break;
  212. X    case 'W': mode=MODE_NEWFILE; break;
  213. X    default : ierror(NULL,500); return;
  214. X    }
  215. Xn=(unsigned int)myatoi(av[3],0,MAXMYFILES-1); if (atoierr) return 20;
  216. Xif (myfile[n]) myclose(n);
  217. Xmyfile[n]=Open(av[1],mode);
  218. Xreturn (myfile[n]==NULL);
  219. X}
  220. X
  221. Xdo_close()
  222. X{
  223. Xregister unsigned int i;
  224. Xint n;
  225. X
  226. Xif (ac==1)
  227. X    for (i=1; i<MAXMYFILES; i++)
  228. X        myclose(i);
  229. Xfor (i=1; i<ac; i++) {
  230. X    n=myatoi(av[i],0,MAXMYFILES-1); if (atoierr) return 20;
  231. X    myclose(n);
  232. X    }
  233. Xreturn 0;
  234. X}
  235. X
  236. Xmyclose(n)
  237. X{
  238. Xif (myfile[n]) { Close(myfile[n]); myfile[n]=NULL; }
  239. X}
  240. X
  241. Xdo_fileslist()
  242. X{
  243. Xregister unsigned short i;
  244. Xint flag=0;
  245. X
  246. Xprintf("Open files:");
  247. Xfor (i=0; i<MAXMYFILES; i++)
  248. X    if (myfile[i]) { printf(" %d",i); flag=1; }
  249. Xif (!flag) printf(" None!");
  250. Xprintf("\n");
  251. Xreturn 0;
  252. X}
  253. X
  254. XBPTR extOpen(name,mode)
  255. Xchar *name;
  256. Xlong mode;
  257. X{
  258. Xif (name[0]=='.') return myfile[atoi(name+1)];
  259. Xreturn Open(name,mode);
  260. X}
  261. X
  262. XextClose(fh)
  263. XBPTR fh;
  264. X{
  265. Xregister unsigned short i;
  266. X
  267. Xfor (i=0; i<MAXMYFILES; i++)
  268. X    if (myfile[i]==fh) return;
  269. XClose(fh);
  270. X}
  271. X
  272. Xdo_basename()
  273. X{
  274. Xset_var(LEVEL_SET, av[1], BaseName(av[2]));
  275. Xreturn 0;
  276. X}
  277. X
  278. Xdo_tackon()
  279. X{
  280. Xchar buf[256];
  281. X
  282. Xstrcpy(buf, av[2]);
  283. XTackOn(buf, av[3]);
  284. Xset_var(LEVEL_SET, av[1], buf);
  285. Xreturn 0;
  286. X}
  287. X
  288. Xdo_resident()
  289. X{
  290. Xunsigned int i;
  291. Xregister struct ResidentProgramNode *p;
  292. Xchar buf[256];
  293. X
  294. Xget_opt("ard", &i);
  295. Xif (options==0 && ac>1) options=1;
  296. Xswitch (options) {
  297. X    case 0:
  298. X    ObtainSemaphore (& (ArpBase->ResPrgProtection) );
  299. X    if (p=ArpBase->ResidentPrgList) {
  300. X        printf("Name             Users Access\n");
  301. X        for (; p; p=p->rpn_Next)
  302. X            printf("%-17s%5ld%6ld\n",
  303. X                p->rpn_Name-2, (long)p->rpn_Usage, (long)p->rpn_AccessCnt);
  304. X        }
  305. X    else printf("No resident program(s)\n");
  306. X    ReleaseSemaphore(& (ArpBase->ResPrgProtection) );
  307. X    break;
  308. X    case 1:
  309. X    for (; i<ac; i++)
  310. X        if (loadres(av[i]))
  311. X            printf("OK! %s is now resident\n", BaseName(av[i]));
  312. X        else pError(av[i]);
  313. X    break;
  314. X    case 2:
  315. X    for (; i<ac; i++)
  316. X        if (RemResidentPrg(av[i])) ierror(av[i],202);
  317. X        else printf("Removed %s\n",av[i]);
  318. X    break;
  319. X    case 4:
  320. X    for (; i<ac; i++) {
  321. X        sprintf(buf,"res_%s",av[i]);
  322. X        Setenv(buf,"1");
  323. X        }
  324. X    break;
  325. X    default:
  326. X    ierror(NULL,500);
  327. X    break;
  328. X    }
  329. Xreturn 0;
  330. X}
  331. X
  332. Xint loadres(s)
  333. Xchar *s;
  334. X{
  335. XBPTR seg;
  336. X
  337. Xif (seg=(BPTR)LoadPrg(s)) AddResidentPrg(seg,BaseName(s));
  338. Xreturn (seg != NULL);
  339. X}
  340. X
  341. Xstruct ProcessControlBlock pcb={
  342. X    4000,        /* pcb_StackSize    */
  343. X    0,        /* pcb_Pri        */
  344. X    };
  345. X/* remaining field are NULL */
  346. X    
  347. Xdo_truerun(avline, backflag)
  348. Xchar *avline;
  349. X{
  350. Xchar name[200];
  351. Xchar *FindIt();
  352. X
  353. Xif (backflag) {
  354. X    pcb.pcb_Control=NULL;
  355. X    pcb.pcb_Input=pcb.pcb_Output=Open("NIL:",MODE_OLDFILE);
  356. X    }
  357. Xelse {
  358. X    pcb.pcb_Control=NULL;
  359. X    pcb.pcb_Input=pcb.pcb_Output =NULL;
  360. X    }
  361. Xif (FindIt(av[1], "", name))
  362. X    ASyncRun(name,next_word(next_word(avline)),&pcb);
  363. Xelse
  364. X    ierror(av[1],205);
  365. Xreturn 0;
  366. X}
  367. X
  368. Xint exists(name)
  369. Xchar *name;
  370. X{
  371. XBPTR lock;
  372. X
  373. Xif (lock=Lock(name,ACCESS_READ)) {
  374. X    UnLock(lock);
  375. X    return 1;
  376. X    }
  377. Xreturn 0;
  378. X}
  379. X
  380. Xdo_aset()
  381. X{
  382. XSetenv(av[1],av[2]);
  383. Xreturn 0;
  384. X}
  385. X
  386. X#define HTYPELINE 16L
  387. X
  388. Xhtype_a_file(s)
  389. Xchar *s;
  390. X{
  391. XBPTR fh;
  392. Xlong n, filesize=0;
  393. Xchar buf[HTYPELINE+1];
  394. Xregister unsigned short i;
  395. X
  396. Xif ( (fh=Open(s,MODE_OLDFILE))==NULL ) { pError(s); return 20; }
  397. Xwhile ( (n=Read(fh,buf,HTYPELINE))>0 && !dobreak()) {
  398. X    printf("%06lx: ",filesize);
  399. X    filesize+=n;
  400. X    for (i=0; i<n; i++) {
  401. X        printf( (i&3) ? "%02x" : " %02x",(int)(unsigned char)buf[i]);
  402. X        if (buf[i]<0x20) buf[i]='.';
  403. X        }
  404. X    for ( ; i<HTYPELINE; i++) {
  405. X        printf( (i&3) ? "  " : "   ");
  406. X        buf[i]=' ';
  407. X        }
  408. X    buf[i]=0;
  409. X    printf("    %s\n",buf);
  410. X    }
  411. XClose(fh);
  412. Xreturn 0;
  413. X}
  414. X
  415. Xdo_htype()
  416. X{
  417. Xall_args("", htype_a_file, 0);
  418. Xreturn 0;
  419. X}
  420. X
  421. Xdo_stack()
  422. X{
  423. Xlong n;
  424. X
  425. Xif (ac>1) {
  426. X    n=Atol(av[1]);
  427. X    if (!IoErr()) Mycli->cli_DefaultStack=(long)(n >> 2L);
  428. X    }
  429. Xelse printf("current stack size is %ld bytes\n",
  430. X                (long)Mycli->cli_DefaultStack << 2L);
  431. Xreturn 0;
  432. X}
  433. X
  434. Xdo_fault()
  435. X{
  436. Xstruct PERROR *p;
  437. Xregister unsigned int i;
  438. Xint n;
  439. X
  440. Xfor (i=1; i<ac; i++) {
  441. X    n=myatoi(av[i],0,32767);
  442. X    if (!atoierr) {
  443. X        for (p=Perror; p->errnum && p->errnum!=n; p++);
  444. X        if (p->errnum)
  445. X            printf("Fault %d: %s\n",n,p->errstr);
  446. X        else
  447. X            printf("Fault %d not recognized\n",n);
  448. X        }
  449. X    }
  450. Xreturn 0;
  451. X}
  452. X
  453. Xstruct rpncommand {
  454. X    char *str;
  455. X    int parsin, parsout;
  456. X    };
  457. X
  458. Xstruct rpncommand rpn[]={
  459. X    "+",    2,    1,
  460. X    "-",    2,    1,
  461. X    "*",    2,    1,
  462. X    "/",    2,    1,
  463. X    "%",    2,    1,
  464. X    "&",    2,    1,
  465. X    "|",    2,    1,
  466. X    "~",    1,    1,
  467. X    ">",    2,    1,
  468. X    "<",    2,    1,
  469. X    "==",    2,    1,
  470. X    "!",    1,    1,
  471. X    "DUP",    1,    2,
  472. X    "DROP",    1,    0,
  473. X    "SWAP",    2,    2,
  474. X    "HELP",    0,    0,
  475. X    NULL,    0,    1,    /* this looks for a number */
  476. X};
  477. X
  478. Xdo_rpn(garbage,ifflag) /* ifflag!=0 if called from if */
  479. Xchar *garbage;
  480. X{
  481. Xregister long n0, n1;
  482. Xlong t;
  483. Xunsigned int i, j;
  484. Xint sp=0;
  485. Xlong stack[100];
  486. Xstruct rpncommand *temp;
  487. X
  488. Xi=1;
  489. Xif (ifflag) get_opt("rn",&i);
  490. Xfor (; i<ac; i++) {
  491. X    for (j=0; rpn[j].str && Strcmp(rpn[j].str,av[i]); j++) ;
  492. X    n0=stack[sp-1];
  493. X    n1=stack[sp-2];
  494. X    sp -= (rpn[j].parsin);
  495. X    if (sp<0) { fprintf(stderr, "RPN: Empty stack\n"); return 1; }
  496. X    switch (j) {
  497. X      case 0:    n0 += n1;        break;
  498. X      case 1:    n0 = n1-n0;        break;
  499. X      case 2:    n0 *= n1;        break;
  500. X      case 3:    n0 = n1/n0;        break;
  501. X      case 4:    n0 = n1%n0;        break;
  502. X      case 5:    n0 &= n1;        break;
  503. X      case 6:    n0 |= n1;        break;
  504. X      case 7:    n0 =  ~n0;        break;
  505. X      case 8:    n0 = (n1 > n0);        break;
  506. X      case 9:    n0 = (n1 < n0);        break;
  507. X      case 10:    n0 = (n0 == n1);    break;
  508. X      case 11:    n0 = !n0;        break;
  509. X      case 12:    n1=n0;            break;
  510. X      case 13:    t=n0; n0=n1; n1=t;    break;
  511. X      case 14:                break;
  512. X      case 15:    printf("In Commands Out\n");
  513. X            for (temp=rpn; temp->str; temp++)
  514. X                printf(" %d %-10s%d\n",
  515. X                temp->parsin,temp->str,temp->parsout);
  516. X            break;
  517. X      default:    n0=Atol(av[i]);
  518. X            if (IoErr()) {
  519. X                fprintf(stderr, "Bad RPN cmd: %s\n",av[i]);
  520. X                return 20;
  521. X                }
  522. X            break;
  523. X      }
  524. X    stack[sp]=n0;
  525. X    stack[sp+1]=n1;
  526. X    sp += rpn[j].parsout;
  527. X    }
  528. Xif (ifflag) return (int)(stack[sp-1]);    /* called from if: return top value */
  529. Xfor (i=sp-1;(int)i>=0;i--) printf("%ld\n", stack[i]); /* else print stack */
  530. Xreturn 0;
  531. X}
  532. X
  533. Xdo_path()
  534. X{
  535. Xunion {    long *lp; long ll; } l;
  536. Xchar buf[256];
  537. X
  538. Xputs("Current dir");
  539. Xl.lp = (long *) Mycli->cli_CommandDir;
  540. Xwhile (l.ll) {
  541. X    l.ll <<= 2;
  542. X    PathName(l.lp[1], buf, 256L);
  543. X    puts(buf);
  544. X    l.ll = *l.lp;
  545. X    }
  546. Xputs("C:");
  547. Xreturn 0;
  548. X}
  549. X
  550. Xdo_pri()
  551. X{
  552. Xint t, pri;
  553. Xstruct Process *proc;
  554. X
  555. Xt=myatoi(av[1],0,20); if (atoierr) return 20;
  556. Xpri=myatoi(av[2],-128,127); if (atoierr) return 20;
  557. XForbid();
  558. Xproc=(t==0 ? Myprocess : FindCLI((long)t));
  559. Xif (proc==NULL) fprintf(stderr, "process not found\n");
  560. X    else SetTaskPri(proc, (long)pri);
  561. XPermit();
  562. Xreturn 0;
  563. X}
  564. X
  565. Xdo_strleft()
  566. X{
  567. Xchar buf[256];
  568. Xint n;
  569. X
  570. Xstrcpy(buf,av[2]);
  571. Xn=myatoi(av[3],1,strlen(buf)); if (atoierr) return 20;
  572. Xbuf[n]='\0';
  573. Xset_var(LEVEL_SET, av[1], buf);
  574. Xreturn 0;
  575. X}
  576. X
  577. Xdo_strright()
  578. X{
  579. Xchar buf[256];
  580. Xint n;
  581. X
  582. Xstrcpy(buf, av[2]);
  583. Xn=myatoi(av[3],1,strlen(buf)); if (atoierr) return 20;
  584. Xset_var(LEVEL_SET, av[1], buf+strlen(buf)-n);
  585. Xreturn 0;
  586. X}
  587. X
  588. Xdo_strmid()
  589. X{
  590. Xchar buf[256];
  591. Xint n1, n2;
  592. X
  593. Xstrcpy(buf, av[2]);
  594. Xn1=myatoi(av[3],1,strlen(buf))-1; if (atoierr) return 20;
  595. Xif (ac>4) {
  596. X    n2=myatoi(av[4],1,strlen(buf)-n1); if (atoierr) return 20;
  597. X    buf[n1+n2]='\0';
  598. X    }
  599. Xset_var(LEVEL_SET, av[1], buf+n1);
  600. Xreturn 0;
  601. X}
  602. X
  603. Xdo_strlen()
  604. X{
  605. Xchar buf[16];
  606. X
  607. Xsprintf(buf,"%d",strlen(av[2]));
  608. Xset_var(LEVEL_SET, av[1], buf);
  609. Xreturn 0;
  610. X}
  611. X
  612. Xint atoierr;
  613. X
  614. Xmyatoi(s,min,max)
  615. Xchar *s;
  616. X{
  617. Xint n;
  618. X
  619. Xn=(int)(long)Atol(s);
  620. Xif (atoierr=IoErr())
  621. X    ierror(s,511);
  622. X    else if (n<min || n>max) {
  623. X        atoierr=1;
  624. X        printf("%s(%d) not in (%d,%d)\n",s,n,min,max);
  625. X        }
  626. Xreturn n;
  627. X}
  628. X
  629. Xdo_fltlower()
  630. X{
  631. Xchar buf[256], *s;
  632. X
  633. Xwhile (!CHECKBREAK() && gets(buf)) {
  634. X    for (s=buf; *s; s++) *s=tolower(*s);
  635. X    puts(buf);
  636. X    }
  637. Xreturn 0;
  638. X}
  639. X
  640. Xdo_fltupper()
  641. X{
  642. Xchar buf[256], *s;
  643. X
  644. Xwhile (!CHECKBREAK() && gets(buf)) {
  645. X    for (s=buf; *s; s++) *s=toupper(*s);
  646. X    puts(buf);
  647. X    }
  648. Xreturn 0;
  649. X}
  650. X
  651. X#define RXFB_RESULT  17
  652. X
  653. Xstatic struct rexxmsg {
  654. X    struct Message cm_Node;
  655. X    LONG   RFU1;
  656. X    LONG   RFU2;
  657. X    LONG   rm_Action;
  658. X    LONG   rm_Result1;
  659. X    LONG   rm_Result2;
  660. X    char   *cm_Args[16];
  661. X    LONG   RFU7;
  662. X    LONG   RFU8;
  663. X    LONG   RFU9;
  664. X    LONG   RFU10;
  665. X    LONG   RFU11;
  666. X    LONG   RFU12;
  667. X} mymsg;
  668. X
  669. Xdo_rxsend()
  670. X{
  671. Xint i=1, resflag;
  672. Xchar *result;
  673. Xstruct MsgPort *port, *reply;
  674. Xlong len;
  675. X
  676. Xget_opt("r", &i);
  677. Xresflag=options;
  678. Xif (!(port = FindPort(av[i++]))) { fprintf(stderr, "No port %s!\n", av[--i]); return 20; }
  679. Xmymsg.cm_Node.mn_Node.ln_Type = NT_MESSAGE;
  680. Xmymsg.cm_Node.mn_Length = sizeof(struct rexxmsg);
  681. Xmymsg.rm_Action = (resflag ? 1L << RXFB_RESULT : 0);
  682. Xif (!(reply = CreatePort(NULL, 0L))) {
  683. X    fprintf(stderr, "No reply port\n");
  684. X    return 20;
  685. X    }
  686. Xmymsg.cm_Node.mn_ReplyPort = reply;
  687. X
  688. Xfor ( ; i<ac; i++) {
  689. X    mymsg.cm_Args[0] = av[i];
  690. X    mymsg.rm_Result2 = 0;    /* clear out the last result. */
  691. X    PutMsg(port, &mymsg.cm_Node);
  692. X    WaitPort(reply);
  693. X
  694. X    if (resflag) {
  695. X        result=(char *)mymsg.rm_Result2;
  696. X        len=*( (long *)(result-4) );
  697. X        if (len<0 || len>256)
  698. X            fprintf(stderr, "Risultato troppo lungo\n");
  699. X        else
  700. X            printf("%s\n", result);
  701. X        FreeMem(result, len);
  702. X        }
  703. X    }
  704. X
  705. Xif (reply) DeletePort(reply);
  706. Xreturn 0;
  707. X}
  708. X
  709. Xdo_rxrec()
  710. X{
  711. Xstruct MsgPort *port;
  712. Xstruct rexxmsg *msg;
  713. Xchar *portname, *str;
  714. X
  715. Xif (ac > 1)
  716. X    portname=av[1];
  717. Xelse
  718. X    portname="rexx_csh";
  719. X
  720. Xport=CreatePort(portname, 0L);
  721. Xif (port==NULL) {
  722. X    fprintf(stderr, "Can't have MsgPort %s\n", portname);
  723. X    return 20;
  724. X    }
  725. Xfor (;;) {
  726. X    WaitPort(port);
  727. X    while (msg=(struct rexxmsg *)GetMsg(port)) {
  728. X        if ( ! Strcmp(msg->cm_Args[0], "bye")) {
  729. X            DeletePort(port);
  730. X            return 0;
  731. X            }
  732. X        exec_command(msg->cm_Args[0]);
  733. X        if (msg->rm_Action & (1L << RXFB_RESULT)) {
  734. X            str = get_var(LEVEL_SET, v_lasterr);
  735. X            msg->rm_Result2=(str) ? atoi(str) : 20;
  736. X            }
  737. X        ReplyMsg((struct Message *)msg);
  738. X        }
  739. X    }
  740. X}
  741. END_OF_FILE
  742. if test 12209 -ne `wc -c <'comm3.c'`; then
  743.     echo shar: \"'comm3.c'\" unpacked with wrong size!
  744. fi
  745. # end of 'comm3.c'
  746. fi
  747. if test -f 'globals.c' -a "${1}" != "-c" ; then 
  748.   echo shar: Will not clobber existing file \"'globals.c'\"
  749. else
  750. echo shar: Extracting \"'globals.c'\" \(3551 characters\)
  751. sed "s/^X//" >'globals.c' <<'END_OF_FILE'
  752. X
  753. X/*
  754. X * GLOBALS.C
  755. X *
  756. X * (c)1986 Matthew Dillon     9 October 1986
  757. X *
  758. X * Version 2.07M by Steve Drew 10-Sep-87
  759. X *
  760. X *    Most global variables.
  761. X *
  762. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  763. X *
  764. X */
  765. X
  766. Xchar v_titlebar    []="_titlebar";    /* Window title                */
  767. Xchar v_prompt    []="_prompt";    /* your prompt (ascii command)        */
  768. Xchar v_hist    []="_history";    /* set history depth (value)        */
  769. Xchar v_histnum    []="_histnum";    /* set history numbering var        */
  770. Xchar v_debug    []="_debug";    /* set debug mode            */
  771. Xchar v_verbose    []="_verbose";    /* set verbose for source files        */
  772. Xchar v_stat    []="_maxerr";    /* worst return value to date        */
  773. Xchar v_lasterr    []="_lasterr";    /* return value from last comm.        */
  774. Xchar v_cwd    []="_cwd";    /* current directory            */
  775. Xchar v_except    []="_except";    /* "nnn;command"            */
  776. Xchar v_passed    []="_passed";    /* passed arguments to source file    */
  777. Xchar v_path    []="_path";    /* search path for external commands    */
  778. Xchar v_gotofwd    []="_gtf";    /* set name for fwd goto name        */
  779. Xchar v_linenum    []="_linenum";    /* name for forline line #        */
  780. X
  781. Xstruct HIST *H_head, *H_tail;    /* HISTORY lists */
  782. X
  783. Xstruct PERROR Perror[]= {    /* error code->string */
  784. X    103,    "Insufficient free storage",
  785. X    105,    "Task table full",
  786. X    120,    "Argument line invalid or too long",
  787. X    121,    "File is not an object module",
  788. X    122,    "Invalid resident library during load",
  789. X    201,    "No default directory",
  790. X    202,    "Object in use",
  791. X    203,    "Object already exists",
  792. X    204,    "Directory not found",
  793. X    205,    "Object not found",
  794. X    206,    "Bad stream name",
  795. X    207,    "Object too large",
  796. X    209,    "Action not known",
  797. X    210,    "Invalid stream component name",
  798. X    211,    "Invalid object lock",
  799. X    212,    "Object not of required type",
  800. X    213,    "Disk not validated",
  801. X    214,    "Disk write protected",
  802. X    215,    "Rename across devices",
  803. X    216,    "Directory not empty",
  804. X    217,    "Too many levels",
  805. X    218,    "Device not mounted",
  806. X    219,    "Seek error",
  807. X    220,    "Comment too long",
  808. X    221,    "Disk full",
  809. X    222,    "File delete protected",
  810. X    223,    "File write protected",
  811. X    224,    "File read protected",
  812. X    225,    "Not a DOS disk",
  813. X    226,    "No disk",
  814. X
  815. X /* custom error messages */
  816. X
  817. X    500,    "Bad arguments",
  818. X    501,    "Label not found",
  819. X    502,    "Must be within source file",
  820. X    503,    "Syntax Error",
  821. X    504,    "Redirection error",
  822. X    505,    "Pipe error",
  823. X    506,    "Too many arguments",
  824. X    507,    "Destination not a directory",
  825. X    508,    "Cannot mv a filesystem",
  826. X    509,    "Error in command name",
  827. X    510,    "Bad drive name",
  828. X    511,    "Illegal number",
  829. X    0,    NULL
  830. X};
  831. X
  832. Xchar *av[MAXAV];        /* Internal argument list        */
  833. Xlong Src_base[MAXSRC];        /* file pointers for source files    */
  834. Xlong Src_pos[MAXSRC];        /* seek position storage for same    */
  835. Xchar If_base[MAXIF];        /* If/Else stack for conditionals    */
  836. Xint H_len, H_tail_base;        /* History associated stuff        */
  837. Xint H_stack;            /* AddHistory disable stack        */
  838. Xint E_stack;            /* Exception disable stack        */
  839. Xint Src_stack, If_stack;    /* Stack Indexes            */
  840. Xint forward_goto;        /* Flag for searching for foward lables    */
  841. Xint ac;                /* Internal argc            */
  842. Xint debug;            /* Debug mode                */
  843. Xint disable;            /* Disable com. execution (conditionals)*/
  844. Xint Verbose;            /* Verbose mode for source files    */
  845. Xint Lastresult;            /* Last return code            */
  846. Xint Exec_abortline;        /* flag to abort rest of line        */
  847. Xint Quit;            /* Quit flag                */
  848. Xlong Cout, Cin;            /* Current input and output file handles*/
  849. Xlong Cout_append;        /* append flag for Cout            */
  850. Xchar *Cin_name, *Cout_name;    /* redirection input/output name or NULL*/
  851. Xchar *Pipe1, *Pipe2;        /* the two pipe temp. files        */
  852. Xstruct Process *Myprocess;
  853. Xstruct CommandLineInterface *Mycli;
  854. Xint S_histlen = 20;        /* Max # history entries        */
  855. Xunsigned int options;
  856. END_OF_FILE
  857. if test 3551 -ne `wc -c <'globals.c'`; then
  858.     echo shar: \"'globals.c'\" unpacked with wrong size!
  859. fi
  860. # end of 'globals.c'
  861. fi
  862. if test -f 'main.c' -a "${1}" != "-c" ; then 
  863.   echo shar: Will not clobber existing file \"'main.c'\"
  864. else
  865. echo shar: Extracting \"'main.c'\" \(4977 characters\)
  866. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  867. X/*
  868. X * MAIN.C
  869. X *
  870. X * Matthew Dillon, 24 Feb 1986
  871. X * (c)1986 Matthew Dillon     9 October 1986
  872. X *
  873. X * Version 2.07M by Steve Drew 10-Sep-87
  874. X *
  875. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  876. X *
  877. X */
  878. X
  879. Xchar shellname[]="Shell V4.00A";
  880. Xchar shellctr []="CshCounter";
  881. X
  882. Xint aux; /* for use with aux: driver */
  883. Xchar *oldtitle;
  884. Xchar trueprompt[100];
  885. Xchar Inline[260];
  886. Xstruct IntuitionBase *IntuitionBase;
  887. Xstruct Window *w;
  888. Xstruct ArpBase *ArpBase;
  889. X
  890. Xmain(argc, argv)
  891. Xregister char *argv[];
  892. X{
  893. X#if RAW_CONSOLE
  894. X    char *rawgets();
  895. X#endif
  896. X
  897. Xregister unsigned int i;
  898. Xextern int Enable_Abort;
  899. Xchar buf[10];
  900. Xstatic char pipe1[32], pipe2[32];
  901. Xstruct Window *getwindow();
  902. X
  903. XArpBase=(struct ArpBase *)OpenLibrary("arp.library",34L);
  904. Xif (ArpBase==NULL) { printf("No arp library\n"); exit(0); }
  905. X
  906. XForbid();
  907. Xi=0;
  908. Xif (Getenv(shellctr,buf,10L)) {
  909. X    i=(int)(long)Atol(buf);
  910. X    if (IoErr()) i=0;
  911. X    }
  912. Xsprintf(buf,"%d",i+1);
  913. XSetenv(shellctr,buf);
  914. XPermit();
  915. X
  916. XIntuitionBase=(struct IntuitionBase *)ArpBase->IntuiBase;
  917. X
  918. Xstdin->_flags    |= 0x80;    /* make sure we're set as a tty */
  919. Xstdout->_flags    |= 0x80;    /* in case of redirection in .login */
  920. XClose(_devtab[2].fd);
  921. X_devtab[2].mode |= O_STDIO;
  922. X_devtab[2].fd = _devtab[1].fd;    /* set stderr to Output() otherwise */
  923. X                /* don't work with aux driver */
  924. XMyprocess = (struct Process *)FindTask(0L);
  925. XMycli=(struct CommandLineInterface *)((long)Myprocess->pr_CLI << 2);
  926. Xw=getwindow();
  927. XPipe1 = pipe1;
  928. XPipe2 = pipe2;
  929. Xsprintf(pipe1, "ram:pipe1_%ld", Myprocess);
  930. Xsprintf(pipe2, "ram:pipe2_%ld", Myprocess);
  931. X
  932. Xsprintf(buf,"%ld",Myprocess->pr_TaskNum);
  933. Xset_var(LEVEL_SET, "_clinumber", buf);
  934. X
  935. Xoldtitle=(char *)(w->Title);
  936. X
  937. Xset_var(LEVEL_SET, v_titlebar, shellname);
  938. Xset_var(LEVEL_SET, v_prompt,
  939. X    (IsInteractive(Input())) ? "\23337m%p> \2330m" : "");
  940. Xset_var(LEVEL_SET, v_hist, "20");
  941. Xset_var(LEVEL_SET, v_lasterr, "0");
  942. Xset_var(LEVEL_SET, v_stat, "0");
  943. Xset_var(LEVEL_SET, v_path, "RAM:,RAM:c/,df0:c/,df1:c/,sys:system/");
  944. Xset_var(LEVEL_SET, "_insert", "1");
  945. Xset_var(LEVEL_SET, "f1", "cdir df0:\15");
  946. Xset_var(LEVEL_SET, "F1", "cdir df1:\15");
  947. Xset_var(LEVEL_SET, "f3", "cdir RAM:\15");
  948. Xset_var(LEVEL_SET, "F3", "cdir vd0:\15");
  949. Xset_var(LEVEL_SET, "f4", "cd df0:\15");
  950. Xset_var(LEVEL_SET, "F4", "cd df1:\15");
  951. Xset_var(LEVEL_SET, "f5", "cls; ls\15");
  952. Xset_var(LEVEL_SET, "F5", "cdir ");
  953. Xset_var(LEVEL_SET, "f6", "lc\15");
  954. Xset_var(LEVEL_SET, "f7", "info\15");
  955. Xset_var(LEVEL_SET, "F7", "assign \15");
  956. Xset_var(LEVEL_SET, "f8", "window -lf\15");
  957. Xset_var(LEVEL_SET, "F8", "window -sb\15");
  958. Xset_var(LEVEL_SET, "f10", "cls\15");
  959. Xset_var(LEVEL_SET, "F10", "exit\15");
  960. Xset_var(LEVEL_ALIAS, "cls", "echo -n ^l");
  961. Xset_var(LEVEL_ALIAS, "lc", "ls -s");
  962. Xset_var(LEVEL_ALIAS, "kr", "rm -r RAM:* >NIL:");
  963. Xset_var(LEVEL_ALIAS, "cdir", "%q cd $q; cls; dir");
  964. Xset_var(LEVEL_ALIAS, "exit", "endcli;quit");
  965. Xset_var(LEVEL_ALIAS, "lp", "cat >PRT:");
  966. Xseterr();
  967. Xif (Myprocess->pr_CurrentDir == NULL)
  968. X    do_cd("x :");
  969. Xelse do_pwd(NULL);
  970. XEnable_Abort = 0;
  971. X
  972. Xif (exists(av[1] = "S:.login")) do_source("x S:.login");
  973. X
  974. Xfor (i = 1; i < argc; ++i) {
  975. X    if (!strcmp(argv[i],"-c")) {
  976. X        Inline[0] = ' ';
  977. X        Inline[1] = '\0';
  978. X        while (++i < argc)
  979. X            { strcat(Inline,argv[i]); strcat(Inline," "); }
  980. X        exec_command(Inline);
  981. X        main_exit(Lastresult);
  982. X        }
  983. X    if (!strcmp(argv[i],"-a")) { aux = 1; continue; }
  984. X    sprintf (Inline, "source %s",argv[i]);
  985. X    av[1] = argv[i];
  986. X    do_source (Inline);
  987. X    }
  988. Xfor (;;) {
  989. X   if (breakcheck())
  990. X    while (WaitForChar(Input(), 100L) || stdin->_bp < stdin->_bend)
  991. X        gets(Inline);
  992. X   clearerr(stdin);  /* prevent acidental quit */
  993. X#if RAW_CONSOLE
  994. X   if (Quit || !rawgets(Inline, disable ? "_ " : trueprompt)) main_exit(0);
  995. X#else
  996. X   printf("%s", disable ? "_ " : trueprompt);
  997. X   fflush(stdout);
  998. X   if (Quit || !gets(Inline)) main_exit(0);
  999. X#endif
  1000. X   breakreset();
  1001. X   if (*Inline) exec_command(Inline);
  1002. X   }
  1003. X}
  1004. X
  1005. Xmain_exit(n)
  1006. X{
  1007. Xregister unsigned short i;
  1008. Xchar buf[10];
  1009. X
  1010. XGetenv(shellctr,buf,10L);
  1011. Xi=(int)Atol(buf);
  1012. Xsprintf(buf,"%d",i-1);
  1013. XSetenv(shellctr,buf);
  1014. XSetWindowTitles(w,oldtitle,-1L);
  1015. Xfor (i=1; i<MAXMYFILES; i++) myclose((int)i);
  1016. XArpExit(0L,0L);            /* Intuition need not to be closed */
  1017. X}
  1018. X
  1019. Xbreakcheck()
  1020. X{
  1021. Xreturn (int)(SetSignal(0L,0L) & SIGBREAKF_CTRL_C);
  1022. X}
  1023. X
  1024. Xbreakreset()
  1025. X{
  1026. XSetSignal(0L, SIGBREAKF_CTRL_C);
  1027. X}
  1028. X
  1029. Xdobreak()
  1030. X{
  1031. Xif (breakcheck()) { printf("^C\n"); return(1); }
  1032. Xreturn(0);
  1033. X}
  1034. X
  1035. X/* this routine causes manx to use this Chk_Abort() rather than it's own */
  1036. X/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
  1037. X/* is zero).  Since we want to check for our own ^C's             */
  1038. X
  1039. XChk_Abort()
  1040. X{
  1041. Xreturn(0);
  1042. X}
  1043. X
  1044. X_wb_parse()
  1045. X{
  1046. X}
  1047. X
  1048. Xdo_howmany()
  1049. X{
  1050. Xchar buf[10];
  1051. X
  1052. XGetenv(shellctr, buf, 10L);
  1053. Xprintf("Shell(s) running: %s\n",buf);
  1054. X}
  1055. X
  1056. Xstruct Window *getwindow()
  1057. X{
  1058. Xstruct InfoData *infodata;
  1059. Xstruct Window *win;
  1060. Xlong args[8];
  1061. X
  1062. Xinfodata=AllocMem((long)sizeof(struct InfoData),MEMF_CLEAR | MEMF_PUBLIC);
  1063. Xargs[0]=(long)infodata >> 2;
  1064. XSendPacket(ACTION_DISK_INFO,args,Myprocess->pr_ConsoleTask);
  1065. Xwin=(struct Window *)infodata->id_VolumeNode;
  1066. XFreeMem(infodata,(long)sizeof(struct InfoData));
  1067. Xreturn win;
  1068. X}
  1069. END_OF_FILE
  1070. if test 4977 -ne `wc -c <'main.c'`; then
  1071.     echo shar: \"'main.c'\" unpacked with wrong size!
  1072. fi
  1073. # end of 'main.c'
  1074. fi
  1075. if test -f 'makefile' -a "${1}" != "-c" ; then 
  1076.   echo shar: Will not clobber existing file \"'makefile'\"
  1077. else
  1078. echo shar: Extracting \"'makefile'\" \(1019 characters\)
  1079. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  1080. X######################################################################
  1081. X#
  1082. X# Makefile to build Shell 4.00A
  1083. X# by Carlo Borreo & Cesare Dieni 13-Gen-90
  1084. X#
  1085. X######################################################################
  1086. X
  1087. XOBJS    = run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o \
  1088. X      globals.o rawconsole.o
  1089. X
  1090. XINCL    = shell.h
  1091. X
  1092. XShell   : Shell.syms $(OBJS)
  1093. X    ln  +q -m -o Shell $(OBJS) -la -lc32
  1094. X
  1095. XShell.syms : $(INCL)
  1096. X    cc +L +HShell.syms shell.h -DAZTEC_C
  1097. X
  1098. Xrawconsole.o : rawconsole.c $(INCL)
  1099. X    cc +L +IShell.syms rawconsole.c
  1100. X
  1101. Xrun.o   : run.c $(INCL)
  1102. X    cc +L +IShell.syms run.c
  1103. X
  1104. Xmain.o  : main.c $(INCL)
  1105. X    cc +L +IShell.syms main.c
  1106. X
  1107. Xcomm1.o : comm1.c $(INCL)
  1108. X    cc +L +IShell.syms comm1.c
  1109. X
  1110. Xcomm2.o : comm2.c $(INCL)
  1111. X    cc +L +IShell.syms comm2.c
  1112. X
  1113. Xcomm3.o : comm3.c $(INCL)
  1114. X    cc +L +IShell.syms comm3.c
  1115. X
  1116. Xset.o   : set.c $(INCL)
  1117. X    cc +L +IShell.syms set.c
  1118. X
  1119. Xsub.o   : sub.c $(INCL)
  1120. X    cc +L +IShell.syms sub.c
  1121. X
  1122. Xglobals.o : globals.c $(INCL)
  1123. X    cc +L +IShell.syms globals.c
  1124. X
  1125. Xexecom.o : execom.c $(INCL)
  1126. X    cc +L +IShell.syms execom.c
  1127. END_OF_FILE
  1128. if test 1019 -ne `wc -c <'makefile'`; then
  1129.     echo shar: \"'makefile'\" unpacked with wrong size!
  1130. fi
  1131. # end of 'makefile'
  1132. fi
  1133. if test -f 'rawconsole.c' -a "${1}" != "-c" ; then 
  1134.   echo shar: Will not clobber existing file \"'rawconsole.c'\"
  1135. else
  1136. echo shar: Extracting \"'rawconsole.c'\" \(9156 characters\)
  1137. sed "s/^X//" >'rawconsole.c' <<'END_OF_FILE'
  1138. X/*
  1139. X * RawConsole.c
  1140. X *
  1141. X * Shell 2.07M  17-Jun-87
  1142. X * console handling, command line editing support for Shell
  1143. X * using new console packets from 1.2.
  1144. X * Written by Steve Drew. (c) 14-Oct-86.
  1145. X * 16-Dec-86 Slight mods to rawgets() for Disktrashing.
  1146. X *
  1147. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  1148. X *
  1149. X */
  1150. X
  1151. X#if RAW_CONSOLE
  1152. X
  1153. Xchar *tyahdptr;
  1154. X
  1155. Xmyget()
  1156. X{
  1157. Xif (*tyahdptr) return *tyahdptr++;
  1158. Xreturn getchar();
  1159. X}
  1160. X
  1161. Xextern int aux; /* for use with aux: */
  1162. X
  1163. X#define SETRAW setrawcon(-1L);
  1164. X#define SETCON setrawcon(0L);
  1165. X
  1166. Xint width;
  1167. X
  1168. Xnewwidth()
  1169. X{
  1170. Xextern struct Window *w;
  1171. X
  1172. Xwidth=(w->Width- (w->BorderLeft + w->BorderRight)) / w->RPort->TxWidth;
  1173. X}
  1174. X
  1175. Xchar *rawgets(line,prompt)
  1176. Xchar *line, *prompt;
  1177. X{
  1178. Xchar *get_var();
  1179. Xchar *gets();
  1180. Xregister int n, pl;
  1181. Xregister int max, i;
  1182. Xunsigned char c1,c2,c3;
  1183. Xchar fkeys[5];
  1184. Xchar *s;
  1185. Xchar *ps;
  1186. Xchar typeahd[256];
  1187. Xint fkey, savn;
  1188. Xint insert = 1;
  1189. Xint recall = -1;
  1190. Xstruct HIST *hist;
  1191. X
  1192. Xnewwidth();
  1193. X
  1194. Xif (aux) {
  1195. X    printf("%s",prompt);
  1196. X    fflush(stdout);
  1197. X    }
  1198. Xif (!IsInteractive(Input()) || aux ) return(gets(line));
  1199. Xif (WaitForChar((long)Input(), 100L) ||   /* don't switch to 1L ...*/
  1200. X        stdin->_bp < stdin->_bend) {     /* else causes read err's*/
  1201. X    gets(line);
  1202. X    return(line);
  1203. X    }
  1204. XSETRAW;
  1205. Xprintf("\015%s\2336n",prompt);
  1206. Xsavn = pl = n = 0;
  1207. Xtyahdptr = typeahd;
  1208. Xwhile((typeahd[n]=getchar()) != 'R') {
  1209. X    if ((unsigned char)typeahd[n] == 155) savn = n;
  1210. X    n++;
  1211. X    }
  1212. X    /* typeahd now contains possible type a head chars
  1213. X       followed by <CSI> cursor position report.
  1214. X    */
  1215. Xtypeahd[savn]  = '\0';
  1216. Xif (typeahd[n-2] != ';') pl = (typeahd[n-2] - 48) * 10;
  1217. Xpl += typeahd[n-1] - 49;
  1218. Xps = line + pl;
  1219. Xline[max = i = pl] = '\0';
  1220. X
  1221. Xif (s = get_var (LEVEL_SET, "_insert")) insert = atoi(s) ? 1 : 0;
  1222. X
  1223. Xwhile( (c1 = myget()) != 255) {
  1224. X        switch(c1) {
  1225. X            case 155:
  1226. X                 c2 = myget();
  1227. X                 switch(c2) {
  1228. X                     case 'A':                  /* up arrow   */
  1229. X                        n = ++recall;
  1230. X                     case 'B':                  /* down arrow */
  1231. X                        line[pl] = '\0';
  1232. X                        if (recall >= 0 || c2 == 'A') {
  1233. X                            if (c2 == 'B') n = --recall;
  1234. X                            if (recall >= 0) {
  1235. X                                for(hist = H_head; hist && n--;
  1236. X                                    hist = hist->next);
  1237. X                                if (hist) strcpy(&line[pl],hist->line);
  1238. X                                else recall = H_len;
  1239. X                            }
  1240. X                        }
  1241. X                        if (i != pl)
  1242. X                            printf("\233%dD",i);
  1243. X                        printf("\015\233J%s%s",prompt,ps);
  1244. X                        i = max = strlen(ps) + pl;
  1245. X                        break;
  1246. X                     case 'C':                  /* right arrow*/
  1247. X                        if (i < max) {
  1248. X                            i++;
  1249. X                            printf("\233C");
  1250. X                        }
  1251. X                        break;
  1252. X                     case 'D':                  /* left arrow */
  1253. X                        if (i > pl) {
  1254. X                            i--;
  1255. X                            printf("\233D");
  1256. X                        }
  1257. X                        break;
  1258. X                     case 'T':           /* shift-up   */
  1259. X                       n = recall = H_len-1;
  1260. X                     case 'S':           /* shift-down */
  1261. X                       line[pl] = '\0';
  1262. X                       if (c2 == 'S') {
  1263. X                           n = recall = 0;
  1264. X                           if (H_head) strcpy(&line[pl], H_head->line);
  1265. X                       }
  1266. X                       else if (H_tail) strcpy(&line[pl], H_tail->line);
  1267. X                       printf("\015\233J%s%s", prompt, ps);
  1268. X                       i = max = strlen(ps) + pl;
  1269. X                       break;
  1270. X                    case ' ':                   /* shift -> <-*/
  1271. X                        c3 = myget();
  1272. X                                     switch(c3) {
  1273. X                    case('@'):      /* shift ->   */
  1274. X                        while (ps[i-pl-1] == ' ' && i<max) {
  1275. X                          i++;
  1276. X                          printf("\233C");
  1277. X                }
  1278. X                        while (ps[i-pl-1] != ' ' && i<max) {
  1279. X                          i++;
  1280. X                    printf("\233C");
  1281. X                       }
  1282. X                        break;
  1283. X                    case('A'):      /* shift <-   */
  1284. X                        while (ps[i-pl-1] == ' ' && i>pl) {
  1285. X                            i--;
  1286. X                            printf("\233D");
  1287. X                        }
  1288. X                        while (ps[i-pl-1] != ' ' && i>pl) {
  1289. X                            i--;
  1290. X                            printf("\233D");
  1291. X                        }
  1292. X                        break;
  1293. X                        default:
  1294. X                        break;
  1295. X                    }
  1296. X                        break;
  1297. X                    default:
  1298. X                        c3 = myget();
  1299. X                        if (c3 == '~') {
  1300. X                            fkey = c2;
  1301. X                            fkeys[0] = 'f';
  1302. X                            if (c2 == '?') {
  1303. X                                strcpy(ps,"help");
  1304. X                                goto done;
  1305. X                            }
  1306. X                        }
  1307. X                        else if (myget() != '~') { /* window was resized */
  1308. X                            while(myget() != '|');
  1309. X                            newwidth();
  1310. X                            break;
  1311. X                        }
  1312. X                        else {
  1313. X                            fkey = c3;
  1314. X                            fkeys[0] = 'F';
  1315. X                        }
  1316. X                        sprintf(fkeys+1,"%d",fkey - 47);
  1317. X                        if (s = get_var(LEVEL_SET, fkeys))
  1318. X                                tyahdptr = strcpy(typeahd,s);
  1319. X                        break;
  1320. X                    }
  1321. X                break;
  1322. X            case 8:
  1323. X                if (i > pl) {
  1324. X                    i--;
  1325. X                    printf("\010");
  1326. X                }
  1327. X                else break;
  1328. X            case 127:
  1329. X                if (i < max) {
  1330. X                    int j,t,l = 0;
  1331. X                    movmem(&line[i+1],&line[i],max-i);
  1332. X                    --max;
  1333. X                    printf("\233P");
  1334. X                    j = width - i % width - 1;   /* amount to end     */
  1335. X                    t = max/width - i/width;     /* no of lines       */
  1336. X                    for(n = 0; n < t; n++) {
  1337. X                        l += j;                  /* no. of char moved */
  1338. X                        if (j) printf("\233%dC",j); /* goto eol       */
  1339. X                        printf("%c\233P",line[width*(i/width+n+1)-1]);
  1340. X                        j = width-1;
  1341. X                    }
  1342. X                    if (t)
  1343. X                    printf("\233%dD",l+t);   /* get back */
  1344. X                }
  1345. X                break;
  1346. X            case 18:
  1347. X                n = i/width;
  1348. X                if (n) printf("\233%dF",n);
  1349. X                printf("\015\233J%s%s",prompt,ps);
  1350. X                i = max;
  1351. X                break;
  1352. X            case 27:
  1353. X                break;
  1354. X            case 1:
  1355. X                insert ^= 1;
  1356. X                break;
  1357. X            case 21:
  1358. X            case 24:
  1359. X            case 26:
  1360. X                if (i>pl) printf("\233%dD",i-pl);
  1361. X                i = pl;
  1362. X                if (c1 == 26) break;
  1363. X            case 11:        /* ^K */
  1364. X                printf("\233J");
  1365. X                max = i;
  1366. X                line[i] = '\0';
  1367. X                break;
  1368. X            case 28:        /* ^\ */
  1369. X                SETCON;
  1370. X                return(NULL);
  1371. X            case 5:
  1372. X                if (i!=max) printf("\233%dC",max - i);
  1373. X                i = max;
  1374. X                break;
  1375. X            case 10:
  1376. X            case 13:
  1377. X                line[max] = '\0';
  1378. Xdone:           printf("\233%dC\n",max - i);
  1379. X
  1380. X                SETCON;
  1381. X                strcpy(line, ps);
  1382. X                return(line);
  1383. X            default:
  1384. X                c1 &= 0x7f;
  1385. X                if (c1 == 9) c1 = 32;
  1386. X                if (c1 > 31 & i < 256) {
  1387. X                    if (i < max && insert) {
  1388. X                        int j,t,l = 0;
  1389. X                        movmem(&line[i], &line[i+1], max - i);
  1390. X                        printf("\233@%c",c1);
  1391. X                        t = max/width - i/width;
  1392. X                        j = width - i % width - 1;
  1393. X                        for(n = 0; n < t; n++) {
  1394. X                            l += j;
  1395. X                            if (j) printf("\233%dC",j);
  1396. X                            printf("\233@%c",line[width*(i/width+n+1)]);
  1397. X                            j = width-1;
  1398. X                        }
  1399. X                        if (t) printf("\233%dD",l + t);
  1400. X                        ++max;
  1401. X                    }
  1402. X                    else {
  1403. X                        if(i == pl && max == i) printf("\015%s%s",prompt,ps);
  1404. X                        putchar(c1);
  1405. X                    }
  1406. X                    line[i++] = c1;
  1407. X                    if (max < i) max = i;
  1408. X                    line[max] = '\0';
  1409. X                }
  1410. X        }
  1411. X    }
  1412. XSETCON;
  1413. Xreturn(NULL);
  1414. X}
  1415. X
  1416. Xsetrawcon(flag) /* -1L=RAW:, 0L=CON: */
  1417. Xlong flag;
  1418. X{
  1419. Xlong packargs[8];
  1420. X
  1421. Xpackargs[0]=flag;
  1422. XSendPacket(994L, packargs, Myprocess->pr_ConsoleTask);
  1423. X}
  1424. X
  1425. X#endif
  1426. END_OF_FILE
  1427. if test 9156 -ne `wc -c <'rawconsole.c'`; then
  1428.     echo shar: \"'rawconsole.c'\" unpacked with wrong size!
  1429. fi
  1430. # end of 'rawconsole.c'
  1431. fi
  1432. if test -f 'run.c' -a "${1}" != "-c" ; then 
  1433.   echo shar: Will not clobber existing file \"'run.c'\"
  1434. else
  1435. echo shar: Extracting \"'run.c'\" \(1712 characters\)
  1436. sed "s/^X//" >'run.c' <<'END_OF_FILE'
  1437. X
  1438. X/*
  1439. X * RUN.C
  1440. X *
  1441. X * (c)1986 Matthew Dillon     9 October 1986
  1442. X *
  1443. X *    RUN   handles running of external commands.
  1444. X *
  1445. X * Version 2.07M by Steve Drew 10-Sep-87
  1446. X *
  1447. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  1448. X *
  1449. X */
  1450. X
  1451. Xchar *FindIt();
  1452. X
  1453. Xdo_run(str)
  1454. Xchar *str;
  1455. X{
  1456. Xint retcode;
  1457. Xchar buf[200]; /* enough space for 100 char cmd name + path stuff */
  1458. Xchar *path, *argline, *trueargline, *copy, *p = av[0];
  1459. X
  1460. Xwhile(*p++) *p &= 0x7F;      /* allow "com mand" */
  1461. X
  1462. Xargline=compile_av(av, 1, ac, ' ', 1);
  1463. Xtrueargline= (*argline ? argline : "\n");
  1464. X
  1465. Xif (strlen(av[0]) > 100) { ierror(NULL,509); return -1; }
  1466. X
  1467. Xsprintf(buf,"res_%s",BaseName(av[0]));
  1468. Xif (Getenv(buf, buf+100, 90L) && loadres(av[0])) Setenv(buf,NULL);
  1469. Xretcode=SyncRun(av[0],trueargline,0L,0L);
  1470. Xif (retcode>=0) { free(argline); return retcode; }
  1471. Xif (path = FindIt(av[0],"",buf)) {
  1472. X    retcode = SyncRun(path,trueargline,0L,0L);
  1473. X    free(argline);
  1474. X    return retcode;
  1475. X    }
  1476. Xelse free(argline);
  1477. Xif ((path = FindIt(av[0],".sh",buf)) == NULL) {
  1478. X    fprintf(stderr,"Command Not Found %s\n",av[0]);
  1479. X    return -1;
  1480. X    }
  1481. Xav[1] = buf;
  1482. Xcopy = malloc(strlen(str)+3);
  1483. Xsprintf(copy,"x %s",str);
  1484. Xretcode = do_source(copy);
  1485. Xfree(copy);
  1486. Xreturn retcode;
  1487. X}
  1488. X
  1489. Xchar *dofind(cmd, ext, buf)
  1490. Xchar *cmd, *ext, *buf;
  1491. X{
  1492. Xchar *ptr, *s;
  1493. X
  1494. Xsprintf(buf,"%s%s",cmd,ext);
  1495. Xif (exists(buf)) return buf;
  1496. Xif (BaseName(buf)==buf) {
  1497. X    s = get_var(LEVEL_SET, v_path);
  1498. X    while (*s) {
  1499. X        for (ptr=buf; *s && *s!=','; ) *ptr++ = *s++;
  1500. X        sprintf(ptr, "%s%s", cmd, ext);
  1501. X        if (exists(buf)) return buf;
  1502. X        if (*s) s++;
  1503. X        }
  1504. X    }
  1505. Xreturn NULL;
  1506. X}
  1507. X
  1508. Xchar *FindIt(cmd,ext,buf)
  1509. Xchar *cmd, *ext, *buf;
  1510. X{
  1511. Xchar *response;
  1512. X
  1513. XMyprocess->pr_WindowPtr = (APTR)(-1);
  1514. Xresponse=dofind(cmd,ext,buf);
  1515. XMyprocess->pr_WindowPtr = NULL;
  1516. Xreturn response;
  1517. X}
  1518. END_OF_FILE
  1519. if test 1712 -ne `wc -c <'run.c'`; then
  1520.     echo shar: \"'run.c'\" unpacked with wrong size!
  1521. fi
  1522. # end of 'run.c'
  1523. fi
  1524. if test -f 'set.c' -a "${1}" != "-c" ; then 
  1525.   echo shar: Will not clobber existing file \"'set.c'\"
  1526. else
  1527. echo shar: Extracting \"'set.c'\" \(3884 characters\)
  1528. sed "s/^X//" >'set.c' <<'END_OF_FILE'
  1529. X
  1530. X/*
  1531. X * SET.C
  1532. X *
  1533. X * (c)1986 Matthew Dillon     9 October 1986
  1534. X *
  1535. X * Version 2.07M by Steve Drew 10-Sep-87
  1536. X *
  1537. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  1538. X *
  1539. X */
  1540. X
  1541. Xextern struct Window *w;
  1542. X
  1543. X#define MAXLEVELS (3 + MAXSRC)
  1544. X
  1545. Xstruct MASTER {
  1546. X    struct MASTER *next;
  1547. X    struct MASTER *last;
  1548. X    char *name;
  1549. X    char *text;
  1550. X};
  1551. X
  1552. Xstatic struct MASTER *Mbase[MAXLEVELS];
  1553. X
  1554. Xchar *set_var(level, name, str)
  1555. Xregister char *name, *str;
  1556. X{
  1557. X   register struct MASTER *base = Mbase[level];
  1558. X   register struct MASTER *last;
  1559. X   register int len;
  1560. X
  1561. X   for (len = 0; isalphanum(name[len]); ++len);
  1562. X   while (base != NULL) {
  1563. X      if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) {
  1564. X         Free (base->text);
  1565. X         goto gotit;
  1566. X      }
  1567. X      last = base;
  1568. X      base = base->next;
  1569. X   }
  1570. X   if (base == Mbase[level]) {
  1571. X      base = Mbase[level] = (struct MASTER *)malloc (sizeof(struct MASTER));
  1572. X      base->last = NULL;
  1573. X   } else {
  1574. X      base = (struct MASTER *)malloc (sizeof(struct MASTER));
  1575. X      base->last = last;
  1576. X      last->next = base;
  1577. X   }
  1578. X   base->name = malloc (len + 1);
  1579. X   bmov (name, base->name, len);
  1580. X   base->name[len] = 0;
  1581. X   base->next = NULL;
  1582. Xgotit:
  1583. X   base->text = malloc (strlen(str) + 1);
  1584. X   strcpy (base->text, str);
  1585. X   if (*name=='_') sys_vars();
  1586. X   return (base->text);
  1587. X}
  1588. X
  1589. Xchar *get_var (level, name)
  1590. Xregister char *name;
  1591. X{
  1592. X   register struct MASTER *base = Mbase[level];
  1593. X   register unsigned char *scr;
  1594. X   register int len;
  1595. X
  1596. X   for (scr = (unsigned char *)name; *scr && *scr != 0x80 && *scr != ' ' && *scr != ';' && *scr != '|'; ++scr);
  1597. X   len = scr - name;
  1598. X
  1599. X   while (base != NULL) {
  1600. X      if (strlen(base->name) == len && strncmp (name, base->name, len) == 0)
  1601. X         return (base->text);
  1602. X      base = base->next;
  1603. X   }
  1604. X   return (NULL);
  1605. X}
  1606. X
  1607. Xunset_level(level)
  1608. X{
  1609. X   register struct MASTER *base = Mbase[level];
  1610. X
  1611. X   while (base) {
  1612. X      Free (base->name);
  1613. X      Free (base->text);
  1614. X      Free (base);
  1615. X      base = base->next;
  1616. X   }
  1617. X   Mbase[level] = NULL;
  1618. X}
  1619. X
  1620. Xunset_var(level, name)
  1621. Xchar *name;
  1622. X{
  1623. X   register struct MASTER *base = Mbase[level];
  1624. X   register struct MASTER *last = NULL;
  1625. X   register int len;
  1626. X
  1627. X   for (len = 0; isalphanum(name[len]); ++len);
  1628. X   while (base) {
  1629. X      if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) {
  1630. X         if (base != Mbase[level])
  1631. X            last->next = base->next;
  1632. X         else
  1633. X            Mbase[level] = base->next;
  1634. X         if (base->next != NULL)
  1635. X            base->next->last = last;
  1636. X         if (base == Mbase[level])
  1637. X            Mbase[level] = base->next;
  1638. X         Free (base->name);
  1639. X         Free (base->text);
  1640. X         Free (base);
  1641. X         return (1);
  1642. X      }
  1643. X      last = base;
  1644. X      base = base->next;
  1645. X   }
  1646. X   return (-1);
  1647. X}
  1648. X
  1649. Xdo_unset_var(str, level)
  1650. Xchar *str;
  1651. X{
  1652. Xregister unsigned int i;
  1653. X
  1654. Xfor (i = 1; i < ac; ++i) unset_var (level, av[i]);
  1655. Xsys_vars();
  1656. Xreturn 0;
  1657. X}
  1658. X
  1659. Xdo_set_var(command, level)
  1660. Xchar *command;
  1661. X{
  1662. Xregister struct MASTER *base = Mbase[level];
  1663. Xregister char *str;
  1664. X
  1665. Xswitch (ac) {
  1666. Xcase 1:
  1667. X    while (base && !dobreak()) {
  1668. X        printf ("\2330m%-10s %s\n", base->name, base->text);
  1669. X        base = base->next;
  1670. X        }
  1671. X    break;
  1672. Xcase 2:
  1673. X    if (str=get_var(level,av[1])) printf ("%-10s %s\n", av[1], str);
  1674. X    break;
  1675. Xdefault:
  1676. X    set_var (level, av[1], next_word (next_word (command)));
  1677. X    if (*av[1]=='_') sys_vars();
  1678. X    break;
  1679. X    }
  1680. Xreturn 0;
  1681. X}
  1682. X
  1683. Xsys_vars()
  1684. X{
  1685. Xregister char *str, *t;
  1686. Xextern char trueprompt[100];
  1687. X
  1688. Xif (strcmp(w->Title, str=get_var(LEVEL_SET, v_titlebar)))
  1689. X    SetWindowTitles(w, str, -1L);
  1690. XS_histlen=(str = get_var(LEVEL_SET, v_hist)) ? atoi(str) : 0;
  1691. Xdebug  =(get_var(LEVEL_SET, v_debug)  !=NULL);
  1692. XVerbose=(get_var(LEVEL_SET, v_verbose)!=NULL);
  1693. Xif (S_histlen < 2) S_histlen=2;
  1694. X
  1695. Xif ( (str=get_var(LEVEL_SET,v_prompt)) ==NULL) str="$ ";
  1696. Xt=trueprompt;
  1697. Xwhile (*str)
  1698. X    if (*str=='%' && str[1]=='p') {
  1699. X        str+=2;
  1700. X        strcpy(t,get_var(LEVEL_SET, "_cwd"));
  1701. X        t+=strlen(t);
  1702. X        }
  1703. X    else *t++=*str++;
  1704. Xstrcpy(t,"\2330m");
  1705. X}
  1706. END_OF_FILE
  1707. if test 3884 -ne `wc -c <'set.c'`; then
  1708.     echo shar: \"'set.c'\" unpacked with wrong size!
  1709. fi
  1710. # end of 'set.c'
  1711. fi
  1712. if test -f 'shell.h' -a "${1}" != "-c" ; then 
  1713.   echo shar: Will not clobber existing file \"'shell.h'\"
  1714. else
  1715. echo shar: Extracting \"'shell.h'\" \(3029 characters\)
  1716. sed "s/^X//" >'shell.h' <<'END_OF_FILE'
  1717. X
  1718. X/*
  1719. X * SHELL.H
  1720. X *
  1721. X * (c)1986 Matthew Dillon     9 October 1986
  1722. X *
  1723. X *
  1724. X * SHELL include file.. contains shell parameters and extern's
  1725. X *
  1726. X * Version 2.07M by Steve Drew 10-Sep-87
  1727. X *
  1728. X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90
  1729. X *
  1730. X */
  1731. X
  1732. X#define RAW_CONSOLE 1   /* Set to 0 to compile out Cmd Line Editing */
  1733. X
  1734. X#include <stdio.h>
  1735. X#include <exec/exec.h>
  1736. X#include <time.h>
  1737. X#include <libraries/dos.h>
  1738. X#include <libraries/dosextens.h>
  1739. X#include <intuition/intuition.h>
  1740. X#include <intuition/intuitionbase.h>
  1741. X#include "shellfunctions.h"
  1742. X#include <fcntl.h>
  1743. X#include <libraries/arpbase.h>
  1744. X
  1745. Xtypedef struct FileInfoBlock FIB;
  1746. X
  1747. X#define bmov movmem
  1748. X
  1749. X#define MAXAV        256        /* Max. # arguments        */
  1750. X#define MAXSRC        5        /* Max. # of source file levels */
  1751. X#define MAXIF        10        /* Max. # of if levels        */
  1752. X#define MAXALIAS    20        /* Max. # of alias levels    */
  1753. X#define MAXMYFILES    9        /* Max. # of internal files    */
  1754. X
  1755. X#define LEVEL_SET    0        /* which variable list to use   */
  1756. X#define LEVEL_ALIAS    1
  1757. X#define LEVEL_LABEL    2
  1758. X
  1759. X    /* EXECOM.C defines */
  1760. X
  1761. X#define FL_DOLLAR    0x01  /* One of the following */
  1762. X#define FL_BANG        0x02
  1763. X#define FL_PERCENT    0x04
  1764. X#define FL_QUOTE    0x08
  1765. X#define FL_IDOLLAR    0x10  /* Any or all of the following may be set */
  1766. X#define FL_EOC        0x20
  1767. X#define FL_EOL        0x40
  1768. X#define FL_OVERIDE    0x80
  1769. X#define FL_WILD        0x100
  1770. X#define FL_MASK        (FL_DOLLAR|FL_BANG|FL_PERCENT|FL_QUOTE)
  1771. X
  1772. X#ifndef NULL
  1773. X#define NULL 0L
  1774. X#endif
  1775. X
  1776. X#define CHECKBREAK() dobreak()
  1777. X
  1778. X#ifndef AZTEC_C
  1779. Xstruct _dev {
  1780. X    long  fd;
  1781. X    short mode;
  1782. X    };
  1783. X#endif
  1784. X
  1785. Xstruct HIST {
  1786. X    struct HIST *next, *prev;    /* doubly linked list */
  1787. X    char *line;            /* line in history    */
  1788. X};
  1789. X
  1790. Xstruct PERROR {
  1791. X    int errnum;            /* Format of global error lookup */
  1792. X    char *errstr;
  1793. X};
  1794. X
  1795. Xstruct DPTR {                /* Format of directory fetch pointer */
  1796. X    BPTR lock;            /* lock on directory   */
  1797. X    FIB *fib;            /* mod'd fib for entry */
  1798. X    };
  1799. X
  1800. Xextern struct HIST *H_head, *H_tail;
  1801. Xextern struct PERROR Perror[];
  1802. Xextern struct DPTR *dopen();
  1803. Xextern char *set_var(), *get_var(), *next_word();
  1804. Xextern char *get_history(), *compile_av(), *get_pwd();
  1805. Xextern char *malloc(), *strcpy(), *strcat(), *index();
  1806. Xextern char **expand();
  1807. Xextern char *av[];
  1808. Xextern char *Current;
  1809. Xextern int  H_len, H_tail_base, H_stack;
  1810. Xextern int  E_stack;
  1811. Xextern int  Src_stack, If_stack, forward_goto;
  1812. Xextern int  ac;
  1813. Xextern int  debug, Rval, Verbose, disable, Quit;
  1814. Xextern int  Lastresult, atoierr;
  1815. Xextern int  Exec_abortline;
  1816. Xextern int   S_histlen;
  1817. Xextern unsigned int options;
  1818. Xextern long  Cin, Cout, Cout_append;
  1819. Xextern char *Cin_name, *Cout_name;
  1820. Xextern char  Cin_type,  Cout_type;  /* these variables are in transition */
  1821. Xextern char *Pipe1, *Pipe2;
  1822. X
  1823. Xextern long Src_base[MAXSRC];
  1824. Xextern long Src_pos[MAXSRC];
  1825. Xextern char If_base[MAXIF];
  1826. Xextern struct Process *Myprocess;
  1827. Xextern struct CommandLineInterface *Mycli;
  1828. X
  1829. Xextern struct ArpBase *ArpBase;
  1830. X
  1831. Xextern long atol(), Atol(), myatol();
  1832. X
  1833. Xextern char    v_titlebar[], v_prompt[], v_hist[], v_histnum[], v_debug[],
  1834. X        v_verbose[], v_stat[], v_lasterr[], v_cwd[], v_except[],
  1835. X        v_passed[], v_path[], v_gotofwd[], v_linenum[];
  1836. END_OF_FILE
  1837. if test 3029 -ne `wc -c <'shell.h'`; then
  1838.     echo shar: \"'shell.h'\" unpacked with wrong size!
  1839. fi
  1840. # end of 'shell.h'
  1841. fi
  1842. if test -f 'shellfunctions.h' -a "${1}" != "-c" ; then 
  1843.   echo shar: Will not clobber existing file \"'shellfunctions.h'\"
  1844. else
  1845. echo shar: Extracting \"'shellfunctions.h'\" \(9694 characters\)
  1846. sed "s/^X//" >'shellfunctions.h' <<'END_OF_FILE'
  1847. Xtypedef    long    cList;
  1848. Xextern int Enable_Abort;
  1849. X
  1850. Xlong                    AbleICR();
  1851. Xlong                    AbortIO();
  1852. Xlong                    ActivateGadget();
  1853. Xvoid                    ActivateWindow();
  1854. Xvoid                    AddAnimOb();
  1855. Xvoid                    AddBob();
  1856. Xvoid                    AddConfigDev();
  1857. Xvoid                    AddDevice();
  1858. Xlong                    AddDosNode();
  1859. Xvoid                    AddFont();
  1860. Xvoid                    AddFreeList();
  1861. Xshort                    AddGadget();
  1862. Xunsigned short                AddGList();
  1863. Xvoid                    AddHead();
  1864. Xstruct Interrupt *            AddICRVector();
  1865. Xvoid                    AddIntServer();
  1866. Xvoid                    AddLibrary();
  1867. Xlong                    AddMemList();
  1868. Xvoid                    AddPort();
  1869. Xvoid                    AddResource();
  1870. Xvoid                    AddSemaphore();
  1871. Xvoid                    AddTail();
  1872. Xvoid                    AddTask();
  1873. Xvoid                    AddTime();
  1874. Xvoid                    AddVSprite();
  1875. Xlong                    Alert();
  1876. Xvoid *                    AllocAbs();
  1877. Xlong                    AllocBoardMem();
  1878. XcList                    AllocCList();
  1879. Xstruct ConfigDev *            AllocConfigDev();
  1880. Xstruct MemList *            AllocEntry();
  1881. Xunsigned long                AllocExpansionMem();
  1882. Xvoid *                    AllocMem();
  1883. Xlong                    AllocPotBits();
  1884. Xvoid *                    AllocRaster();
  1885. Xchar *                    AllocRemember();
  1886. Xlong                    AllocSignal();
  1887. Xlong                    AllocTrap();
  1888. Xstruct WBObject *            AllocWBObject();
  1889. Xvoid *                    Allocate();
  1890. Xvoid                    AlohaWorkbench();
  1891. Xvoid                    AndRectRegion();
  1892. Xlong                    AndRegionRegion();
  1893. Xvoid                    Animate();
  1894. Xshort                    AreaDraw();
  1895. Xlong                    AreaEllipse();
  1896. Xvoid                    AreaEnd();
  1897. Xshort                    AreaMove();
  1898. Xvoid                    AskFont();
  1899. Xlong                    AskSoftStyle();
  1900. Xlong                    AttemptLockLayerRom();
  1901. Xlong                    AttemptSemaphore();
  1902. Xshort                    AutoRequest();
  1903. Xlong                    AvailFonts();
  1904. Xlong                    AvailMem();
  1905. Xvoid                    BeginIO();
  1906. Xvoid                    BeginRefresh();
  1907. Xvoid                    BeginUpdate();
  1908. Xvoid                    BeginLayer();
  1909. Xlong                    BltBitMap();
  1910. Xlong                    BltBitMapRastPort();
  1911. Xvoid                    BltClear();
  1912. Xvoid                    BltMaskBitMapRastPort();
  1913. Xvoid                    BltPattern();
  1914. Xvoid                    BltTemplate();
  1915. Xstruct Window *                BuildSysRequest();
  1916. Xchar *                    BumpRevision();
  1917. Xvoid                    Cause();
  1918. Xvoid                    CBump();
  1919. Xstruct Events *                CDInputHandler();
  1920. Xvoid                    ChangeSprite();
  1921. Xstruct IORequest *            CheckIO();
  1922. Xshort                    ClearDMRequest();
  1923. Xvoid                    ClearEOL();
  1924. Xvoid                    ClearMenuStrip();
  1925. Xvoid                    ClearPointer();
  1926. Xvoid                    ClearRegion();
  1927. Xlong                    ClearRectRegion();
  1928. Xvoid                    ClearScreen();
  1929. Xvoid                    ClipBit();
  1930. Xvoid                    Close();
  1931. Xvoid                    CloseDevice();
  1932. Xvoid                    CloseFont();
  1933. Xvoid                    CloseLibrary();
  1934. Xvoid                    CloseScreen();
  1935. Xvoid                    CloseWindow();
  1936. Xshort                    CloseWorkBench();
  1937. Xvoid                    CMove();
  1938. Xshort                    CmpTime();
  1939. Xlong                    ConcatCList();
  1940. Xlong                    ConfigBoard();
  1941. Xlong                    ConfigChain();
  1942. Xlong                    ConsoleDevice();
  1943. Xlong                    CopperListInit();
  1944. XcList                    CopyCList();
  1945. Xvoid                    CopyMem();
  1946. Xvoid                    CopyMemQuick();
  1947. Xvoid                    CopySBitMap();
  1948. Xstruct Layer *                CreateBehindLayer();
  1949. XBPTR        CreateDir();
  1950. Xstruct MsgPort *            CreatePort();
  1951. Xstruct Process *            CreateProc();
  1952. Xstruct IOStdReq *            CreateStdIO();
  1953. Xstruct Task *                CreateTask();
  1954. Xstruct Layer *                CreateUpfrontLayer();
  1955. XBPTR                    CurrentDir();
  1956. Xvoid                    CurrentTime();
  1957. Xvoid                    CWait();
  1958. Xlong *                    DateStamp();
  1959. Xvoid                    Deallocate();
  1960. Xvoid                    Debug();
  1961. Xvoid                    Delay();
  1962. Xshort                    DeleteFile();
  1963. Xvoid                    DeleteLayer();
  1964. Xvoid                    DeletePort();
  1965. Xvoid                    DeleteStdIO();
  1966. Xvoid                    DeleteTask();
  1967. Xstruct Process *            DeviceProc();
  1968. Xvoid                    Disable();
  1969. Xvoid                    DisownBlitter();
  1970. Xshort                    DisplayAlert();
  1971. Xvoid                    DisplayBeep();
  1972. Xvoid                    DisposeRegion();
  1973. Xvoid                    DoCollision();
  1974. Xlong                    DoIO();
  1975. Xshort                    DoubleClick();
  1976. Xvoid                    Draw();
  1977. Xvoid                    DrawBorder();
  1978. Xvoid                    DrawEllipse();
  1979. Xvoid                    DrawGList();
  1980. Xvoid                    DrawImage();
  1981. XBPTR                    DupLock();
  1982. Xvoid                    Enable();
  1983. Xvoid                    EndRefresh();
  1984. Xvoid                    EndRequest();
  1985. Xvoid                    EndUpdate();
  1986. Xvoid                    Enqueue();
  1987. Xshort                    ExNext();
  1988. Xshort                    Examine();
  1989. Xshort                    Execute();
  1990. Xvoid                    Exit();
  1991. Xstruct ConfigDev *            FindConfigDev();
  1992. Xstruct Node *                FindName();
  1993. Xstruct MsgPort *            FindPort();
  1994. Xstruct Resident *            FindResident();
  1995. Xstruct SignalSemaphore *        FindSemaphore();
  1996. Xstruct Task *                FindTask();
  1997. Xchar *                    FindToolType();
  1998. Xshort                    Flood();
  1999. Xvoid                    FlushCList();
  2000. Xvoid                    Forbid();
  2001. Xvoid                    FreeBoardMem();
  2002. Xvoid                    FreeCList();
  2003. Xvoid                    FreeColorMap();
  2004. Xvoid                    FreeConfigDev();
  2005. Xvoid                    FreeCopList();
  2006. Xvoid                    FreeCprList();
  2007. Xvoid                    FreeDiskObject();
  2008. Xvoid                    FreeEntry();
  2009. Xvoid                    FreeExpansionMem();
  2010. Xvoid                    FreeFreeList();
  2011. Xvoid                    FreeGBuffers();
  2012. Xvoid                    FreeMem();
  2013. Xvoid                    FreePotBits();
  2014. Xvoid                    FreeRaster();
  2015. Xvoid                    FreeRemember();
  2016. Xvoid                    FreeSignal();
  2017. Xvoid                    FreeSprite();
  2018. Xvoid                    FreeSysRequest();
  2019. Xvoid                    FreeTrap();
  2020. Xvoid                    FreeVPortCopLists();
  2021. Xvoid                    FreeWBObject();
  2022. Xlong                    GetCC();
  2023. Xlong                    GetCLBuf();
  2024. Xshort                    GetCLChar();
  2025. Xshort                    GetCLWord();
  2026. Xstruct ColorMap *            GetColorMap();
  2027. Xlong                    GetCurrentBinding();
  2028. Xstruct Preferences *            GetDefPrefs();
  2029. Xstruct DiskObject *            GetDiskObject();
  2030. Xshort                    GetGBuffers();
  2031. Xlong                    GetIcon();
  2032. Xstruct Message *            GetMsg();
  2033. Xstruct Preferences *            GetPrefs();
  2034. Xshort                    GetRGB4();
  2035. Xlong                    GetScreenData();
  2036. Xshort                    GetSprite();
  2037. Xstruct WBObject *            GetWBObject();
  2038. Xlong                    IncrCLMark();
  2039. Xshort                    Info();
  2040. Xvoid                    InitArea();
  2041. Xvoid                    InitBitMap();
  2042. Xlong                    InitCLPool();
  2043. Xvoid                    InitCode();
  2044. Xvoid                    InitGMasks();
  2045. Xvoid                    InitGels();
  2046. Xvoid                    InitMasks();
  2047. Xvoid                    InitRastPort();
  2048. Xvoid                    InitRequester();
  2049. Xvoid                    InitResident();
  2050. Xvoid                    InitSemaphore();
  2051. Xvoid                    InitStruct();
  2052. Xvoid                    InitTmpRas();
  2053. Xvoid                    InitVPort();
  2054. Xvoid                    InitView();
  2055. XBPTR                    Input();
  2056. Xvoid                    Insert();
  2057. Xstruct Region *                InstallClipRegion();
  2058. Xlong                    IntuiTextLength();
  2059. Xstruct InputEvent *            Intuition();
  2060. Xlong                    IoErr();
  2061. Xshort                    IsInteractive();
  2062. Xstruct MenuItem *            ItemAddress();
  2063. Xvoid                    LoadRGB4();
  2064. Xstruct Segment *            LoadSeg();
  2065. Xvoid                    LoadView();
  2066. XBPTR                    Lock();
  2067. Xvoid                    LockLayer();
  2068. Xvoid                    LockLayerInfo();
  2069. Xvoid                    LockLayerRom();
  2070. Xvoid                    LockLayers();
  2071. Xstruct DeviceNode *            MakeDosNode();
  2072. Xlong                    MakeFunctions();
  2073. Xstruct Library *            MakeLibrary();
  2074. Xvoid                    MakeScreen();
  2075. Xvoid                    MakeVPort();
  2076. Xlong                    MarkCList();
  2077. Xlong                    MatchToolValue();
  2078. Xvoid                    ModifyIDCMP();
  2079. Xvoid                    ModifyProp();
  2080. Xvoid                    Move();
  2081. Xlong                    MoveLayer();
  2082. Xvoid                    MoveScreen();
  2083. Xvoid                    MoveSprite();
  2084. Xvoid                    MoveWindow();
  2085. Xvoid                    MrgCop();
  2086. Xvoid                    NewList();
  2087. Xvoid                    NewModifyProp();
  2088. Xstruct Region *                NewRegion();
  2089. Xvoid                    ObtainConfigBinding();
  2090. Xvoid                    ObtainSemaphore();
  2091. Xvoid                    ObtainSemaphoreList();
  2092. Xvoid                    OffGadget();
  2093. Xvoid                    OffMenu();
  2094. Xvoid                    OnGadget();
  2095. Xvoid                    OnMenu();
  2096. XBPTR                    Open();
  2097. Xlong                    OpenDevice();
  2098. Xstruct Font *                OpenDiskFont();
  2099. Xstruct Font *                OpenFont();
  2100. Xvoid                    OpenIntuition();
  2101. Xstruct Library *            OpenLibrary();
  2102. Xstruct MiscResource *            OpenResource();
  2103. Xstruct Screen *                OpenScreen();
  2104. Xstruct Window *                OpenWindow();
  2105. Xshort                    OpenWorkBench();
  2106. Xvoid                    OrRectRegion();
  2107. Xlong                    OrRegionRegion();
  2108. XBPTR                    Output();
  2109. Xvoid                    OwnBlitter();
  2110. XBPTR                    ParentDir();
  2111. Xshort                    PeekCLMark();
  2112. Xvoid                    Permit();
  2113. Xvoid                    PolyDraw();
  2114. Xvoid                    PrintIText();
  2115. Xlong                    PutCLBuf();
  2116. Xlong                    PutCLChar();
  2117. Xlong                    PutCLWord();
  2118. Xshort                    PutDiskObject();
  2119. Xlong                    PutIcon();
  2120. Xvoid                    PutMsg();
  2121. Xlong                    PutWBObject();
  2122. Xvoid                    QBSBlit();
  2123. Xvoid                    QBlit();
  2124. Xshort                    RawKeyConvert();
  2125. Xlong                    Read();
  2126. Xchar                    ReadExpansionByte();
  2127. Xlong                    ReadExpansionRom();
  2128. Xshort                    ReadPixel();
  2129. Xvoid                    RectFill();
  2130. Xvoid                    RefreshGadgets();
  2131. Xvoid                    RefreshGList();
  2132. Xvoid                    RefreshWindowFrame();
  2133. Xvoid                    ReleaseConfigBinding();
  2134. Xvoid                    ReleaseSemaphore();
  2135. Xvoid                    ReleaseSemaphoreList();
  2136. Xvoid                    RemConfigDev();
  2137. Xlong                    RemDevice();
  2138. Xvoid                    RemFont();
  2139. Xstruct Node *                RemHead();
  2140. Xvoid                    RemIBob();
  2141. Xvoid                    RemICRVector();
  2142. Xvoid                    RemIntServer();
  2143. Xlong                    RemLibrary();
  2144. Xunsigned short                RemoveGList();
  2145. Xvoid                    RemPort();
  2146. Xvoid                    RemResource();
  2147. Xvoid                    RemSemaphore();
  2148. Xstruct Node *                RemTail();
  2149. Xvoid                    RemTask();
  2150. Xvoid                    RemVSprite();
  2151. Xvoid                    RemakeDisplay();
  2152. Xvoid                    Remove();
  2153. Xunsigned short                RemoveGadget();
  2154. Xshort                    Rename();
  2155. Xvoid                    ReplyMsg();
  2156. Xvoid                    ReportMouse();
  2157. Xshort                    Request();
  2158. Xvoid                    RethinkDisplay();
  2159. Xvoid                    ScreenToBack();
  2160. Xvoid                    ScreenToFront();
  2161. Xvoid                    ScrollLayer();
  2162. Xvoid                    ScrollRaster();
  2163. Xvoid                    ScrollVPort();
  2164. Xlong                    Seek();
  2165. Xvoid                    SendIO();
  2166. Xvoid                    SetAPen();
  2167. Xvoid                    SetBPen();
  2168. Xvoid                    SetCollision();
  2169. Xshort                    SetComment();
  2170. Xvoid                    SetCurrentBinding();
  2171. Xshort                    SetDMRequest();
  2172. Xvoid                    SetDRMd();
  2173. Xlong                    SetExcept();
  2174. Xlong                    SetFont();
  2175. Xlong                    SetFunction();
  2176. Xlong                    SetICR();
  2177. Xstruct Interrupt *            SetIntVector();
  2178. Xshort                    SetMenuStrip();
  2179. Xvoid                    SetPointer();
  2180. Xstruct Preferences *            SetPrefs();
  2181. Xshort                    SetProtection();
  2182. Xvoid                    SetRast();
  2183. Xvoid                    SetRGB4();
  2184. Xvoid                    SetRGB4CM();
  2185. Xlong                    SetSR();
  2186. Xlong                    SetSignal();
  2187. Xlong                    SetSoftStyle();
  2188. Xshort                    SetTaskPri();
  2189. Xvoid                    SetWindowTitles();
  2190. Xvoid                    ShowTitle();
  2191. Xvoid                    Signal();
  2192. Xlong                    SizeCList();
  2193. Xshort                    SizeLayer();
  2194. Xvoid                    SizeWindow();
  2195. Xvoid                    SortGList();
  2196. XcList                    SplitCList();
  2197. XcList                    SubCList();
  2198. Xvoid                    SubTime();
  2199. Xvoid                    SubLibrary();
  2200. Xvoid                    SumKickData();
  2201. Xlong                    SuperState();
  2202. Xvoid                    SwapBitsRastPortClipRect();
  2203. Xvoid                    SyncSBitMap();
  2204. Xlong                    Text();
  2205. Xlong                    TextLength();
  2206. Xlong                    Translate();
  2207. Xlong                    UnGetCLChar();
  2208. Xlong                    UnGetCLWord();
  2209. Xvoid                    UnLoadSeg();
  2210. Xvoid                    UnLock();
  2211. Xshort                    UnPutCLChar();
  2212. Xshort                    UnPutCLWord();
  2213. Xvoid                    UnlockLayer();
  2214. Xvoid                    UnlockLayerInfo();
  2215. Xvoid                    UnlockLayerRom();
  2216. Xvoid                    UnlockLayers();
  2217. Xshort                    UpfrontLayer();
  2218. Xvoid                    UserState();
  2219. Xshort                    VBeamPos();
  2220. Xstruct View *                ViewAddress();
  2221. Xstruct ViewPort *            ViewPortAddress();
  2222. Xshort                    WBenchToBack();
  2223. Xshort                    WBenchToFront();
  2224. Xlong                    Wait();
  2225. Xvoid                    WaitBOVP();
  2226. Xvoid                    WaitBlit();
  2227. Xshort                    WaitForChar();
  2228. Xlong                    WaitIO();
  2229. Xstruct Message *            WaitPort();
  2230. Xvoid                    WaitTOF();
  2231. Xstruct Layer *                WhichLayer();
  2232. Xshort                    WindowLimits();
  2233. Xvoid                    WindowToBack();
  2234. Xvoid                    WindowToFront();
  2235. Xlong                    Write();
  2236. Xlong                    WriteExpansionByte();
  2237. Xvoid                    WritePixel();
  2238. Xvoid                    WritePotgo();
  2239. Xvoid                    XorRectRegion();
  2240. Xlong                    XorRegionRegion();
  2241. END_OF_FILE
  2242. if test 9694 -ne `wc -c <'shellfunctions.h'`; then
  2243.     echo shar: \"'shellfunctions.h'\" unpacked with wrong size!
  2244. fi
  2245. # end of 'shellfunctions.h'
  2246. fi
  2247. echo shar: End of archive 1 \(of 4\).
  2248. cp /dev/null ark1isdone
  2249. MISSING=""
  2250. for I in 1 2 3 4 ; do
  2251.     if test ! -f ark${I}isdone ; then
  2252.     MISSING="${MISSING} ${I}"
  2253.     fi
  2254. done
  2255. if test "${MISSING}" = "" ; then
  2256.     echo You have unpacked all 4 archives.
  2257.     rm -f ark[1-9]isdone
  2258. else
  2259.     echo You still need to unpack the following archives:
  2260.     echo "        " ${MISSING}
  2261. fi
  2262. ##  End of shell archive.
  2263. exit 0
  2264. -- 
  2265. Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to:
  2266.     amiga@cs.odu.edu    
  2267. or    amiga@xanth.cs.odu.edu    ( obsolescent mailers may need this address )
  2268. or    ...!uunet!xanth!amiga    ( very obsolescent mailers need this address )
  2269.  
  2270. Comments, questions, and suggestions s should be addressed to ``amiga-request''
  2271. (only use ``amiga'' for submissions) at the above addresses.
  2272.